//这里写接口请求

import axios from "./axios";

/*export const getMenu=(param)=>{
  return axios.request({
    url:'http://123.207.32.32:8000/home/multidata',//接口地址
    method:'get',//接口类型
    data:param//传入的参数
  })
}*/
//写好接口调用时
//引用 import {getMenu方法名称} from '这个文件的相对地址'
//mounted() {
//     getMenu().then(res=>{
//       console.log(res)
//     })
//   }

export const getLogin = (params) => {//登录验证
  return axios.request({
    url: 'http://42.193.219.14:8080/login',//接口地址
    method: 'post',
    headers: {
      "Content-Type": "application/json",
    },
    data: params
  }).then(function (params) {
    return params.data
  })
}

export const registerAccount = (params) => {//注册账号
  return axios.request({
    url: 'http://42.193.219.14:8080/registerAccount',//接口地址
    method: 'post',
    headers: {
      "Content-Type": "application/json",
    },
    data: params
  })
}

export const getPaperMessage = () => {//获取试卷信息
  return axios.request({
    url: 'http://42.193.219.14:8080/getTaskPublishExamByUid',//接口地址
    method: 'get',
    headers: {"Authorization": "Bearer "+ sessionStorage.getItem('token')},
  }).then(function (params) {
    return params.data;
  })
}

export const judgmentStartTask = (examId) => {//是否开始考试
  return axios.request({
    url: 'http://42.193.219.14:8080/judgmentStartTask',//接口地址
    method: 'get',
    headers: {"Authorization": "Bearer "+ sessionStorage.getItem('token')},
    params: { examId: examId }
  }).then(function (params) {
    return params.data;
  })
}

export const startExam = (params) => {//获取考试试卷信息
  return axios.request({
    url: 'http://42.193.219.14:8080/startExam',
    method: 'post',
    headers: {'Content-Type': 'application/json',
      "Authorization": "Bearer "+ sessionStorage.getItem('token')},
    data: params
  })
}

export const endExam = (params) => {//上传答题信息
  return axios.request({
    url: 'http://42.193.219.14:8080/paperAnswers',
    method: 'post',
    headers: {'Content-Type': 'application/json',
      "Authorization": "Bearer "+ sessionStorage.getItem('token')},
    data: params
  })
}

export const randImage = (params) => {//上传抓拍图片
  return axios.request({
    url: 'http://42.193.219.14:8080/faceRecognition',
    method: 'post',
    headers: {'Content-Type': 'application/json',
      "Authorization": "Bearer "+ sessionStorage.getItem('token')},
    data: params
  })
}

export const addFace = (params) => {//添加人脸信息
  return axios.request({
    url: 'http://42.193.219.14:8080/addFace',
    method: 'post',
    headers: {'Content-Type': 'application/json',
      "Authorization": "Bearer "+ sessionStorage.getItem('token')},
    data: params,
  })
}

export const joinClass = (params) => {//添加班级
  return axios.request({
    url: 'http://42.193.219.14:8080/joinClass',
    method: 'post',
    name: params,
    headers: {'Content-Type': 'application/json',
      "Authorization": "Bearer "+ sessionStorage.getItem('token')},
    data: params
  })
}

export const returnOriginalState = (examId) => {//教师端是否返回什么信息
  return axios.request({
    url: 'http://42.193.219.14:8080/returnOriginalState',//接口地址
    method: 'get',
    headers: {"Authorization": "Bearer "+ sessionStorage.getItem('token')},
    params: { examId: examId }
  }).then(function (params) {
    return params.data;
  })
}

export const addFaceToTeacher = (params) => {//将照片发送给老师
  return axios.request({
    url: 'http://42.193.219.14:8080/addFaceToTeacher',
    method: 'post',
    name: params,
    headers: {'Content-Type': 'application/json',
      "Authorization": "Bearer "+ sessionStorage.getItem('token')},
    data: params
  })
}
